home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / MacTCP / MacTCP Developer Tools / HyperCard MacTCP Toolkit 1.0 / Source Code ƒ / TCPCharsAvailable.p < prev    next >
Encoding:
Text File  |  1994-11-21  |  1.6 KB  |  66 lines  |  [TEXT/MPS ]

  1. (*
  2.     TCPCharsAvailable(connectionID) -- Return the number of characters available for reading from the TCP connection.
  3.  
  4.     To compile and link this file using Macintosh Programmer's Workshop,
  5.  
  6.         pascal -w TCPCharsAvailable.p
  7.         link -m ENTRYPOINT -o HyperCommands -rt XFCN=7862 -sn Main=TCPCharsAvailable ∂
  8.             TCPCharsAvailable.p.o "{Libraries}HyperXLib.o" "{MPW}"Libraries:interface.o
  9.  
  10.     © Copyright 1988 by Apple Computer, Inc.
  11.  
  12.     Initial coding 12/88 by Harry R. Chesley.
  13. *)
  14.  
  15. {$R-}
  16.  
  17. {$S TCPCharsAvailable }     { Segment name must be the same as the command name. }
  18.  
  19. unit DummyUnit;
  20.  
  21. interface
  22.  
  23. uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
  24.  
  25. procedure EntryPoint(paramPtr: XCmdPtr);
  26.     
  27. implementation
  28.  
  29. procedure TCPCharsAvailable(paramPtr: XCmdPtr); forward;
  30.  
  31. procedure EntryPoint(paramPtr: XCmdPtr);
  32.  
  33.     begin
  34.         TCPCharsAvailable(paramPtr);
  35.     end;
  36.  
  37. procedure TCPCharsAvailable(paramPtr: XCmdPtr);
  38.  
  39.     var l: longInt;
  40.         resultStr: Str255;
  41.  
  42.     procedure Fail(errMsg: Str255); { set theResult and quit }
  43.         begin
  44.             paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
  45.             exit(TCPCharsAvailable);
  46.         end;
  47.  
  48.     {$I TCPUtil.inc}
  49.  
  50.     begin
  51.         if paramPtr^.paramCount <> 1 then Fail('§§§ parameter count is not 1 §§§');
  52.  
  53.         SetUpConnectionID;
  54.  
  55.         { Get the status of the connection. }
  56.         ZeroIOParms;
  57.         SyncControlBlock.csCode := TCPcsStatus;
  58.         if PBControl(@SyncControlBlock,false) <> noErr then Fail('§§§ status call failed §§§');
  59.  
  60.         { Return the number of characters in our buffer, plus the number waiting to be read. }
  61.         LongToStr(paramPtr,ControlWordAtOffset(60)+Connection^.incomingSize,resultStr);
  62.         paramPtr^.returnValue := PasToZero(paramPtr,resultStr)
  63.     end;
  64.  
  65. end.
  66.